import com.lucnn.diamond.spring.bean.Person;
import com.lucnn.diamond.spring.config.ScopeConfig;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;

public class IocTestScope {

    ApplicationContext ctx = new AnnotationConfigApplicationContext(ScopeConfig.class);

    @Test
    public void test01(){
        Person p1 = ctx.getBean(Person.class);
        Person p2 = ctx.getBean(Person.class);
        System.out.println(p1==p2);
    }

    @Test
    public void test02(){
        Environment env =  ctx.getEnvironment();
        String osname = env.getProperty("os.name");
        System.out.println(osname);
        String[] names = ctx.getBeanNamesForType(Person.class);
        for(String name:names){
            System.out.println(name);
        }

        Person p = ctx.getBean(Person.class);
        System.out.println(p);
    }


}
